package com.yupi.springbootinit.controller;


import com.yupi.springbootinit.common.BaseResponse;
import com.yupi.springbootinit.enums.SearchKeyWord;
import com.yupi.springbootinit.model.vo.SearchVo;
import com.yupi.springbootinit.service.UserSearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/search")
@Slf4j
public class SearchController {


    @Resource
    private UserSearchService userSearchService;


    @GetMapping("/search")
    public BaseResponse<SearchVo> search(@RequestParam(required = false) String searchText,
                                         @RequestParam(required = false) SearchKeyWord keyWord,
                                         @RequestParam int paeSize,
                                         @RequestParam int pageNo) {
        SearchVo search = userSearchService.allSearch(searchText, paeSize, pageNo);
        return new BaseResponse<SearchVo>(200, search);
    }

}
